Google SoC Project proposal: Wcoercion option

2006-04-24 Thread lopezibanez
Dear all,

I would like to participate in the Google Summer of Code with GCC as
the mentoring organisation working in the project described below.
This is a draft of the project proposal I am preparing to submit to
Google. Any comments and suggestions (and criticism) are welcome.
Also, if someone wants to participate as a mentor for this project
[*], please get in contact with Ian Lance Taylor 
and me.

Thanks in advance,

Manuel López-Ibáñez.


[*] http://code.google.com/soc/mentorfaq.html



Google Summer of Code Project Proposal

Wcoercion option: warn of any implicit conversion
  that may change a value

 Manuel López-Ibáñez
   ([EMAIL PROTECTED])

---
Summary
---

The goal of this project is to develop an option warning of any
implicit conversion that may change a value. Examples of such
conversions are passing a double value to a function declared to receive
a float argument and setting a signed constant to an unsigned
variable. The option should not warn of explicit conversions or of
cases where the value cannot in fact change despite the implicit
conversion. These options would be particularly useful for security
auditing and scientific applications.


-
Rationale
-

In its most recent version, GCC features only a handful of warning
options for potentially problematic type conversions. As explained in
the GCC manual page, the option Wsign-compare warns of comparisons
between signed and unsigned values that could produce an incorrect
result when the signed value is converted to unsigned. In addition,
the Wconversion option "warns if a prototype causes a type conversion
that is different from what would happen to the same argument in the
absence of such prototype". Wconversion also warns if a negative
integer constant expression is implicitly converted into an unsigned
type.

In particular, Wconversion is frequently misused to warn about type
conversions that may change a value[1]. The confusion between the
documented behaviour and the intention of the user often results in
numerous warnings for perfectly working code [2][3]. Moreover, there
have been proposals for dividing the two different behaviours of
Wconversion into two distinct options [4], and for renaming
Wconversion and creating a new option[5][6].

The proposal of Joseph Myers[6] defines the basic goal of this
project, which is to create a new option: Wcoercion. This new option
will warn for any implicit conversion that may alter a value. Such
option is common in other compilers [7] and it has been mentioned as a
desirable feature in GCC [8].



---
Roadmap
---

* Documentation: writing a clear description of the new option, the
  cases where it should apply and its expected behaviour.
  A short description of the option purpose would be the basis of its
  description in the manual of GCC.

* Coding of the testcases into an example program. This program would be
  the basis for testing the new option.

* Implementation of the option. This will be accomplished in several
  steps. First the basic infrastructure for the option will be added.
  Then, each testcase may be implemented as an individual patch. The
  implementation would be based on that of Wconversion and
  Wsign-compare.

I understand that the code may not be incorporated into GCC's main
development trunk during the Summer of Code 2006. Therefore, my
intention is to synchronise the patch with the latest version of GCC
until the code is ready to be integrated into the main development
trunk, after the work developed for the Google Summer of Code.

Finally, I intend to follow the guidelines of contribution to GCC [9]
and any advice received from GCC developers.



About me


My name is Manuel López-Ibáñez, I was born in 1980 in Spain. I studied
Computer Engineering (5 years degree) at the University of Granada
(Spain). Currently, I am pursuing a PhD by thesis at Napier University
in Edinburgh (United Kingdom).

Website: http://sbe.napier.ac.uk/~manuel/

The motivation for this project arised when I misused the Wconversion
option for warning about implicit conversions in a scientific library.
Then, I started gathering information about the current status of
Wconversion as well as the possibility and importance of a new option.
I have good knowledge of both C and Subversion and I am used to
working with patches and GNU tools. I am genuinely looking forward to
learning from this project. I hope my relevant abilities and a little
help from the community will suffice to make this project useful for
everybody.


 [1] http://groups.google.com/group/gnu.gcc.bug/msg/1e8545e6b7e03320
 [2] http://www.gnu.org/software/libc/FAQ.html#s-3.17
 [3] http://gcc.gnu.org/ml/gcc-bugs/1999-08n/msg00591.html
 [4] http://lists.debian.org/debian-gcc/2002/12/msg00159.html
 [5] http://lists.debian.org/debian-gcc/2003/02/msg00079.html
  [6] http://www.srcf.ucam.org/~js

Re: Google SoC Project proposal: Wcoercion option

2006-05-04 Thread lopezibanez

Hi Ian,

I have submitted the project proposal to Google so it should be
available to GCC for review.
Although I cannot edit it anymore, any comment, criticism (even in the
language, I am not native English-speaker) would be welcome.

Cheers,
Manu.


On 26 Apr 2006 10:05:34 -0700, Ian Lance Taylor  wrote:

[EMAIL PROTECTED] writes:

> I would like to participate in the Google Summer of Code with GCC as
> the mentoring organisation working in the project described below.
> This is a draft of the project proposal I am preparing to submit to
> Google. Any comments and suggestions (and criticism) are welcome.
> Also, if someone wants to participate as a mentor for this project
> [*], please get in contact with Ian Lance Taylor 
> and me.

This looks like a good plan to me, well described, well thought out,
and doable.  Please submit it to Summer of Code when they start taking
student applications on May 1.

I'm willing to act as the mentor on this project, although it's fine
with me if somebody else wants to take it on.

Thanks!

Ian



Re: Google SoC Project proposal: Wcoercion option

2006-05-04 Thread lopezibanez

Hi Grabiel,

On 26 Apr 2006 20:36:27 +0200, Gabriel Dos Reis
<[EMAIL PROTECTED]> wrote:

I hope that does not fire up warnings for the following case and variants

   struct A { /* ... */ };
   struct B { /* ... */ };
   struct C : A, B { /* ... */ };

  void f(B*);

  C c;
  f(&c);

as the call to f(), implies an implicit conversion from C to B, that
alters the value of "&c".



I am sorry to say that I don't understand the definition of struct C.
Would you please write an example that compiles?

Anyway, I plan to divide the different cases into several patches, so
each case can be reviewed and tested independently. Also, I will send
each patch and testcases the list, so I am looking forward to reading
your review. It would be quite an achievement for me to see the option
merged into GCC mainline, so it is my intention to follow developers'
comments, and not to push or force any personal agenda.

Cheers,
  Manu.


Re: Google SoC Project proposal: Wcoercion option

2006-05-07 Thread lopezibanez

On 06/05/06, Mike Stump <[EMAIL PROTECTED]> wrote:

On May 4, 2006, at 4:44 PM, [EMAIL PROTECTED] wrote:
>>struct C : A, B { /* ... */ };
>
> I am sorry to say that I don't understand the definition of struct C.

C is derived from A and B.  Only valid of course in C++.



OK. This is multiple inheritance. I must admit I have never used this
feature with structs. Also, my plan was to start with C and from
simple types to more complex ones. Nevertheless, this may be an
opportunity to refresh my C++ and also to learn about the internals of
g++ and how to properly define Wcoercion in the context of classes and
inheritance.

I created the following test program from your example:

#include 
using namespace std;

struct A { int i; };
struct B { double i; };
struct C : A,B { long double i; };

void fB(struct B* b);
void fB(struct B* b)
{
   cout << sizeof(b) << ", " << b << endl;
   return;
}
void fC(struct C* c);
void fC(struct C* c)
{
   cout << sizeof(c) << ", " << c << endl;
   return;
}

int main(void)
{
   struct C c;
   cout << sizeof(&c) << ", " << &c << endl;
   fB(&c);
   fC(&c);
   return 0;
}

The output is:
4, 0xbfe8c4f0
4, 0xbfe8c4f4
4, 0xbfe8c4f0

and thus, in the case of fB() there is a coercion that changes a value
that doesn't happen for fC(). However, you can never use b as (C *).
That would produce a compilation error.

Honestly, I see that there is a change of value, however, I don't see
what problems may arise from such change (apart from the situation
where you compare the values of the pointers). Until new arguments are
provided, my provisional decision would be to include this testcase as
one that should not generate a warning.

Gabriel, do you mind if I include your email address in the
description of the testcase for future reference?

Cheers,
Manu.


Re: -Wextra and unsigned template parameters

2006-05-10 Thread lopezibanez

On 10/05/06, Aliesha Finkel <[EMAIL PROTECTED]> wrote:


template 
struct foo {
  foo(T bar) { if (bar >= 0) bar = 1; }
};

If foo is instantiated elsewhere then
this check could still be useful.



My opinion is that since it may be instantiated as an signed type,
then warning is pointless there.  Is this a bug?


Re: -Wextra and unsigned template parameters

2006-05-10 Thread lopezibanez

On 10/05/06, Joe Buck <[EMAIL PROTECTED]> wrote:


But then I just thought of another case:

template 
struct foo {
   foo(const Container& bar) { if (bar.size() >= 0) use(bar); }
};

For any STL-compliant container the test is redundant.  But if
we put in a rule saying to suppress the warning if the type
depends on a template, we lose the warning in this case as well;
after all, nothing stops someone from writing

class C {
public:
int size() const;
...
};

void use(const C&);



My STL may be a bit rusty...if you don't define size(), what is its
return type?. Also, there should be no warning in this example, am I
wrong?


Re: how to make gcc stop when there is a warning

2006-05-12 Thread lopezibanez

Richard, if the documentation would have said explicitly that Werror
"makes warnings to prevent compilation", would you have understood it
better?

One proposal:

-Werror  makes all warnings into errors, preventing compilation (see
also -Wfatal-errors).


On 12/05/06, Richard Guenther <[EMAIL PROTECTED]> wrote:

On 5/12/06, D. Ensign <[EMAIL PROTECTED]> wrote:
> > > I'd like to tell gcc to quit when a warning is encountered
> > > (or even if a specific warning is encountered). Is there a way to do
> > > this?
> >
> > Yes.  -Werror.  If you can tell us why you weren't able to find it in
> > the documentation, perhaps we can address that!
>
> Partly, because I never learned to read. Partly, I'm impatient. Partly, 
because when any
> search containing "warning" is extremely unhelpful when you actually LIKE the 
warnings.
> Partly, the man page says, "Make all warnings into errors" for -Werror when 
perhaps it
> should say, "Treat warnings as errors: stop compilation immediately," or 
something like
> that. The latter might, however, have something to do with my not being able 
to read.

Use -Werror -Wfatal-errors (that will stop after the first error, not
trying to continue).

Richard.



problem with GCC Wiki

2006-05-15 Thread lopezibanez

Hi,

I was not able to find who is maintaining the GCC Wiki at
http://gcc.gnu.org/wiki/HomePage
I have found one strange problem and I would like to discuss it in private.

Thanks,

Manuel.

PS: I have noticed that Andrew Pinski is notified of page changes. On
the other hand, many changes have been done also by Daniel Berlin. I
decided that the best way to find out the actual maintainer was to
write here, rather than pestering individual people one by one. I hope
not to cause much trouble if I chose the wrong decision.


GCC 2006 Summer of Code accepted projects

2006-05-24 Thread lopezibanez

Hi,

I guess everybody is very busy. However, it would be nice to set up a
page in the GCC Wiki with the list of projects accepted for this year
SoC and some links. If someone has this information, I would volunteer
to "wikify" it.

Cheers,
Manuel.

PS: yeah, I am also interested part ;-) I would do it, though, even if
I am not accepted. Come on! It would be just 20 minutes...


Re: GCC 2006 Summer of Code accepted projects

2006-05-25 Thread lopezibanez

Daniel, I think it is not a problem that this info appears also in the
GCC wiki, is it?

Thus, tonight, I will write it down in the GCC wiki for further
reference. If someone wishes to send me further information (links to
blogs or webpages), you are welcome to send it to my email address.
My intention is to document the progress in my project in the GCC
wiki, so if you decide to do something similar, just send me the link
(or add it yourself once the page is up).

Cheers,
Manuel.





On 25/05/06, Daniel Berlin <[EMAIL PROTECTED]> wrote:

Ian Lance Taylor wrote:
> "Paul Biggar" <[EMAIL PROTECTED]> writes:
>
>>> Google approved six applications for gcc for Summer of Code 2006.
>>> They are:
>>>
>>> Code parallelization using polyhdral model Plesco Alexandru
>>> Escape analysisPaul Biggar
>>> Garbage collection tuning  Laurynas Biveinis
>>> java.lang.management in Classpath  Andrew John Hughes
>>> Lock free C++ containers   Phillip Jordan
>>> Wcoercion option   Manuel López-Ibáñez
>>
>> I can't find my mentor listed in the SOC website anyhwere. Do you have
>> the list of mentors too?

I believe we are going to get this stuff posted to the soc website today.

>
> Sure.  Here is the mentor list by student.
>
> Plesco AlexandruDaniel Berlin
> Paul Biggar Daniel Berlin
> Laurynas Biveinis   Daniel Berlin
> Andrew John Hughes  Mark Wielaard
> Phillip Jordan  Benjamin Kosnik
> Manuel López-Ibáñez Ian Lance Taylor
>
> (Daniel is also mentoring four other applications for other
> organizations.  Good thing he's so effective.)

Actually, my name is just as a mentor for a few other orgs as a placeholder.
I'm only mentoring a total of 5, and one of them is a Google app, which
means i'm just making sure the professor and their student are doing
what they should be.

Also, Fyodor (nmap) is mentoring 10 this year :)




Re: GCC 2006 Summer of Code accepted projects

2006-05-25 Thread lopezibanez

Hi,

Projects, students and mentors for SoC 2006 are now listed at
http://gcc.gnu.org/wiki/SummerOfCode
(you may edit it to link to your blog, website, or wiki page).

Cheers,
Manuel.




On 25/05/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Daniel, I think it is not a problem that this info appears also in the
GCC wiki, is it?

Thus, tonight, I will write it down in the GCC wiki for further
reference. If someone wishes to send me further information (links to
blogs or webpages), you are welcome to send it to my email address.
My intention is to document the progress in my project in the GCC
wiki, so if you decide to do something similar, just send me the link
(or add it yourself once the page is up).

Cheers,
Manuel.





On 25/05/06, Daniel Berlin <[EMAIL PROTECTED]> wrote:
> Ian Lance Taylor wrote:
> > "Paul Biggar" <[EMAIL PROTECTED]> writes:
> >
> >>> Google approved six applications for gcc for Summer of Code 2006.
> >>> They are:
> >>>
> >>> Code parallelization using polyhdral model Plesco Alexandru
> >>> Escape analysisPaul Biggar
> >>> Garbage collection tuning  Laurynas Biveinis
> >>> java.lang.management in Classpath  Andrew John Hughes
> >>> Lock free C++ containers   Phillip Jordan
> >>> Wcoercion option   Manuel López-Ibáñez
> >>
> >> I can't find my mentor listed in the SOC website anyhwere. Do you have
> >> the list of mentors too?
>
> I believe we are going to get this stuff posted to the soc website today.
>
> >
> > Sure.  Here is the mentor list by student.
> >
> > Plesco AlexandruDaniel Berlin
> > Paul Biggar Daniel Berlin
> > Laurynas Biveinis   Daniel Berlin
> > Andrew John Hughes  Mark Wielaard
> > Phillip Jordan  Benjamin Kosnik
> > Manuel López-Ibáñez Ian Lance Taylor
> >
> > (Daniel is also mentoring four other applications for other
> > organizations.  Good thing he's so effective.)
>
> Actually, my name is just as a mentor for a few other orgs as a placeholder.
> I'm only mentoring a total of 5, and one of them is a Google app, which
> means i'm just making sure the professor and their student are doing
> what they should be.
>
> Also, Fyodor (nmap) is mentoring 10 this year :)
>
>