#pragma pack(1) vs __attribute__((packed))

2015-06-07 Thread Braden Obrzut
I compiled GCC 5.1 on my PowerMac today and noticed that zip archive 
reading broke in my program.  Upon investigation it seems like GCC is 
adding padding (presumably trailing) to a structure which represents a 
chunk of the archive on disk, which has been declared within #pragma 
pack(1).  Adding __attribute__((packed)) to the structure does bring the 
structure to the correct size, but from what I understand this is a GCC 
specific feature.


The following structure can demonstrate the problem on PowerPC:

struct S1 {
uint32_t x;
uint16_t y;
};

On x86 #pragma pack(1) will make sizeof(S1) == 6.  On PowerPC without 
__attribute__((packed)) it is 8.  I do believe I found #pragma pack to 
be working as some other, more complex, structures end up with less 
padding, but not to the extent of the attribute. (Somewhat peculiarly, 
swapping the two members results in the structure being the expected 
size.  I assume it's done to try to keep accesses to x aligned, and in 
the swapped case not padding the end means the access would be aligned 
every other array element.)


Is this difference in behavior between the two features, which sound 
like they should be doing the same thing, intentional?  The change 
appears to have happened around GCC 4.4 as 4.2 behaves as expected 
(haven't tested 4.3 yet).


- Braden Obrzut


[GSoC] Function parameter scope

2014-05-17 Thread Braden Obrzut
Hello,

I'm trying to figure out how to bring variables into scope
temporarily.  The issue we're having is parsing something like:

auto f1(auto x) requires MyConcept() { }

This is similar to the late return type code, but we want to parse
this during cp_parser_init_declarator instead of during
cp_parser_direct_declarator.  The problem is that direct_declarator
closes the scope of the function arguments (as it should) so we get an
error about
x not being in scope.

I think the easiest solution would be to simply re-enter the scope
stored in declarator->u.function.parameters, but from what I can tell
this isn't just a matter of calling push_scope and pop_scope?

- Braden Obrzut


GSoC Concepts - separate checking

2014-03-11 Thread Braden Obrzut

My name is Braden Obrzut and I am a student from the University of Akron
interested in contributing to GCC for GSoC.  I am interested in working on a
project related to the c++-concepts branch.

In particular, I am interested in implementing mechanisms for checking the
safety of constrained templates (separate checking). I have discussed the
project with Andrew Sutton (who maintains the c++-concepts branch and 
happens
to be a professor at Akron) and believe that some aspects of the work 
would be
feasible within the three month time span. I also hope to continue 
working on

the project as my honors thesis project.

As a hobby I usually design and implement declarative languages for content
definition in old video games.  While I currently may have limited 
experience
with GCC internals, I think this would be a great opportunity for me to 
learn
how real compilers works and help with the development of the C++ 
programming

language.


Re: GSoC Concepts - separate checking

2014-03-20 Thread Braden Obrzut

On 03/18/2014 10:54 PM, Maxim Kuvyrkov wrote:

On Mar 12, 2014, at 12:19 PM, Braden Obrzut  wrote:


My name is Braden Obrzut and I am a student from the University of Akron
interested in contributing to GCC for GSoC.  I am interested in working on a
project related to the c++-concepts branch.

In particular, I am interested in implementing mechanisms for checking the
safety of constrained templates (separate checking). I have discussed the
project with Andrew Sutton (who maintains the c++-concepts branch and happens
to be a professor at Akron) and believe that some aspects of the work would be
feasible within the three month time span. I also hope to continue working on
the project as my honors thesis project.

As a hobby I usually design and implement declarative languages for content
definition in old video games.  While I currently may have limited experience
with GCC internals, I think this would be a great opportunity for me to learn
how real compilers works and help with the development of the C++ programming
language.

Braden,

Do you have a proposal for a GSoC GCC project?  If you do want to apply, please 
make sure you are registered at the GSoC website and have a application filed 
by end of Thursday (only 2 days left!).

Thank you,

--
Maxim Kuvyrkov
www.linaro.org

I have just now submitted the proposal to the GSoC website.

- Braden Obrzut